//package com.boarsoft.boar.eureka;
//
//import java.util.ArrayList;
//import java.util.List;
//
//import javax.annotation.PostConstruct;
//import javax.annotation.PreDestroy;
//import javax.annotation.Resource;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//
//import com.boarsoft.soagov.registry.ServiceRegistry;
//import com.netflix.appinfo.ApplicationInfoManager;
//import com.netflix.appinfo.EurekaInstanceConfig;
//import com.netflix.appinfo.InstanceInfo;
//import com.netflix.appinfo.MyDataCenterInstanceConfig;
//import com.netflix.appinfo.providers.EurekaConfigBasedInstanceInfoProvider;
//import com.netflix.discovery.DefaultEurekaClientConfig;
//import com.netflix.discovery.DiscoveryClient;
//import com.netflix.discovery.EurekaClient;
//
//@Resource(name = "eurekaClient")
//// @Component
//public class BoarEurekaClient implements ServiceRegistry {
//	private static final Logger log = LoggerFactory.getLogger(BoarEurekaClient.class);
//
//	private ApplicationInfoManager applicationInfoManager;
//	private EurekaClient eurekaClient;
//
//	@PostConstruct
//	public void init() {
//		EurekaInstanceConfig instanceConfig = new MyDataCenterInstanceConfig();
//		InstanceInfo instanceInfo = new EurekaConfigBasedInstanceInfoProvider(instanceConfig).get();
//		applicationInfoManager = new ApplicationInfoManager(instanceConfig, instanceInfo);
//		eurekaClient = new DiscoveryClient(applicationInfoManager, new DefaultEurekaClientConfig());
//	}
//
//	// shutdown the client
//	@PreDestroy
//	public void destroy() {
//		eurekaClient.shutdown();
//	}
//
//	@Override
//	public List<String> getProviders(String sk) {
//		List<String> rLt = new ArrayList<>();
//		try {
//			List<InstanceInfo> aLt = eurekaClient.getInstancesByVipAddress(sk, false);
//			for (InstanceInfo a : aLt) {
//				rLt.add(new StringBuilder().append(a.getIPAddr())//
//						.append(":").append(a.getPort()).toString());
//			}
//		} catch (Exception e) {
//			log.error("Cannot get instances of service {}", sk);
//		}
//		return rLt;
//	}
//}